﻿using Himp.DataHub.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;

namespace Himp.DataHub.Permissions;

public class DataHubPermissionDefinitionProvider : PermissionDefinitionProvider
{
    public override void Define(IPermissionDefinitionContext context)
    {
        SetDepts(context);
    }

    private void SetDepts(IPermissionDefinitionContext context)
    {
        //科室
        var deptsGroup = context.AddGroup(DataHubPermissions.DeptsGroupName, L(DataHubPermissions.DeptsGroupName));
        var deptInfoPermission = deptsGroup.AddPermission(DataHubPermissions.DeptGroup.DeptInfo, L(DataHubPermissions.DeptGroup.DeptInfo));
        deptInfoPermission.AddChild(DataHubPermissions.DeptGroup.DeptInfoCreate, L(DataHubPermissions.DeptGroup.DeptInfoCreate));
        deptInfoPermission.AddChild(DataHubPermissions.DeptGroup.DeptInfoEdit, L(DataHubPermissions.DeptGroup.DeptInfoEdit));
        deptInfoPermission.AddChild(DataHubPermissions.DeptGroup.DeptInfoDelete, L(DataHubPermissions.DeptGroup.DeptInfoDelete));
    }

    private static LocalizableString L(string name)
    {
        return LocalizableString.Create<DataHubResource>(name);
    }
}
